<?php
/**
 * TinyMVC - autoload.function.php file
 *
 * @author Adrian Wieczorek <adi(at)tinymvc(dot)org>
 * @package TinyMVC
 * @version $Id: autoload.function.php 12 2007-12-19 09:49:02Z adi3ek $
 *
 */

/**
 * @param string $className
 */
function __autoload($className) {
	if($className == 'TinyMVC') {
		// TinyMVC class is called before include_path setting, so we do the trick here
		require_once(realpath(dirname(__FILE__)) . '/TinyMVC.class.php');
	}
	else {
		try {
			@include_once($className . '.class.php');
			if(!class_exists($className) && !interface_exists($className)) {
				throw new TinyMVCException("Unable to load reqired class: $className (include_path='" . ini_get('include_path') . "')");
			}
		}
		catch(Exception $exception) {
			$exception->handleException();
		}
	}
}
